<<<<<<< HEAD
<?php
if (! defined ( 'BASEPATH' ))
	exit ( 'No direct script access allowed' );

class Phonecode extends MY_Controller {
	
	function __construct() {
		parent::__construct ();
	/** 登陆验证 */
	}
	
	/*
	 * 手机验证码发送 
	 * */
	public function apply_phone() {
		$ret = array ('msg' => '', 'url' => '' );
		$k = md5 ( 'zhsjr_activity' );
		if (isset ( $_COOKIE [$k] ) && $_COOKIE [$k] == 1) {
			$ret ['msg'] = '限制3分钟内获取多次次短信验证码，请稍后再试';
			echo json_encode ( $ret );
			exit ();
		} else {
			$phone = $this->input->post ( 'phone' );
			if (! $phone) {
				$ret ['msg'] = '请填写手机号码';
			} elseif (! $this->myformcheck->isPhone ( $phone )) {
				$ret ['msg'] = '请填写有效的手机号码';
			} else {
				//验证手机号码是否存在
				$this->load->model("Actpresellnum_model","presellnum");
				$row = $this->presellnum->get_num_by_phone($phone);
				if (isset ( $row ['presell_num'] ) ) {
					$ret ['msg'] = '您已经领取过预售卷号：'.$row ['presell_num'];
				}
			
			}
			if ($ret ['msg']) {
				echo json_encode($ret);
				exit ();
			}
			$md5 = rand_string ( $phone, 5, 3, 13 );		
			$msg = "尊敬的客户，您的手机验证码为：" . $md5;	
			$this->load->library ( 'phone' );
			$res = $this->phone->send($phone ,$msg );
			if ($res == '0') {
				$ctime = time () + 3 * 60; //限制3分钟内获取多次次短信验证码
				setcookie ( $k, 1, $ctime);
				$this->session->set_userdata ( $phone."_actv", $md5 );
				$ret ['info'] = '1';
			} else {
				$ret ['msg'] = '手机短信发送失败【'.$res.'】，请稍后再试';
			}
			echo json_encode ( $ret );
			exit ();
		
		}
	
	}
	
}
=======
<?php
if (! defined ( 'BASEPATH' ))
    exit ( 'No direct script access allowed' );

class Phonecode extends MY_Controller {
	
	function __construct() {
		parent::__construct ();
	/** 登陆验证 */
	}
	
	/*
	 * 手机验证码发送 
	 * */
	public function apply_phone() {
		$ret = array ('msg' => '', 'url' => '' );
		$k = md5 ( 'zhsjr_activity' );
		if (isset ( $_COOKIE [$k] ) && $_COOKIE [$k] == 1) {
			$ret ['msg'] = '限制3分钟内获取多次次短信验证码，请稍后再试';
			echo json_encode ( $ret );
			exit ();
		} else {
			$phone = $this->input->post ( 'phone' );
			if (! $phone) {
				$ret ['msg'] = '请填写手机号码';
			} elseif (! $this->myformcheck->isPhone ( $phone )) {
				$ret ['msg'] = '请填写有效的手机号码';
			} else {
				//验证手机号码是否存在
				$this->load->model("Actpresellnum_model","presellnum");
				$row = $this->presellnum->get_num_by_phone($phone);
				if (isset ( $row ['presell_num'] ) ) {
					$ret ['msg'] = '您已经领取过预售卷号：'.$row ['presell_num'];
				}
			
			}
			if ($ret ['msg']) {
				echo json_encode($ret);
				exit ();
			}
			$md5 = rand_string ( $phone, 5, 3, 13 );		
			$msg = "尊敬的客户，您的手机验证码为：" . $md5;	
			$this->load->library ( 'phone' );
			$res = $this->phone->send($phone ,$msg );
			if ($res == '0') {
				$ctime = time () + 3 * 60; //限制3分钟内获取多次次短信验证码
				setcookie ( $k, 1, $ctime);
				$this->session->set_userdata ( $phone."_actv", $md5 );
				$ret ['info'] = '1';
			} else {
				$ret ['msg'] = '手机短信发送失败【'.$res.'】，请稍后再试';
			}
			echo json_encode ( $ret );
			exit ();
		
		}
	
	}
	
}
>>>>>>> d47623b610d79a4eeb489500830c00d70933f414
